package thread09.thread;

class MyThread2 implements Runnable
{
	private String name;
	
	public MyThread2()
	{
		
	}
	public MyThread2(String name)
	{
		super();
		this.name = name;
	}

	public void run()
	{
		for(int i=0;i<50;i++)
		{
			System.out.println(name+"="+Thread.currentThread().getName()+"i="+i);
		}
	}
}
public class ThreadDemo09
{


	public static void main(String[] args)
	{
		MyThread2 mt1 = new MyThread2("A");
		Thread t  = new Thread(mt1);
		t.setDaemon(false);
		t.start();
		for(int i=0;i<50;i++)
		{
			if(i>10)
			{
				try
				{
					t.join();
				}
				catch(InterruptedException e)
				{
					// TODO Auto-generated catch block
					e.printStackTrace();
				}
			}
			System.out.println("主线程"+i);
		}
		System.out.println("线程是否存活："+t.isAlive());
		
		System.out.println("线程是否是后台进程："+t.isDaemon());
		t.interrupt();
		System.out.println("线程是否存活："+t.isInterrupted());
		
		new Thread(mt1).run();	
	}

}
